package org.playground.booking.utils;

import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;

import static org.apache.log4j.Logger.getLogger;

@Aspect
public class LoggerAspect {

    public void logBefore(JoinPoint joinPoint){
        Class declaredType = joinPoint.getTarget().getClass();
        Logger logger = getLogger(declaredType);
        String methodName = joinPoint.getSignature().getName();

        logger.info("The beginning of the execution of : "+methodName);
    }


    public void logAfter(JoinPoint joinPoint){
        Class declaredType = joinPoint.getTarget().getClass();
        Logger logger = getLogger(declaredType);
        String methodName = joinPoint.getSignature().getName();

        logger.info("The end of the execution of : "+methodName);
    }


}
